package cn.cmcc.s2a.action;

import static com.opensymphony.xwork2.Action.SUCCESS;

import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import cn.cmcc.s2a.data.Message;

import com.opensymphony.xwork2.ActionSupport;

/**
 * @author cj772929989@gmail.com
 * 
 */
// @ParentPackage("default-package")
@Results( {
		@Result(name = SUCCESS, location = "/success.jsp"),
		@Result(name = "redirectMethod", type = "redirect", location = "hello.jsp") })
public class HelloAction extends ActionSupport {

	private static final long serialVersionUID = 103440136744664832L;

	private Message msg = new Message();
	private String str;
	private int count;

	@Override
	public String execute() throws Exception {
		msg.setContent("Test struts2 demo; class");
		return SUCCESS;
	}

	public String redirectMethod() {
		msg.setContent("index;class");
		setStr("i have value;class");
		setCount(getCount() + 1);
		return "redirectMethod";
	}

	public Message getMsg() {
		return msg;
	}

	public void setMsg(Message msg) {
		this.msg = msg;
	}

	public String getStr() {
		return str;
	}

	public void setStr(String str) {
		this.str = str;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

}
